<?php

$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';

$setting=$this->setting;
$tabs=array(
	array('op'=>'list','title'=>'售后群管理'),
);
set_html('tabs',$tabs);
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if($_RQ['status']!='all' && isset($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
	}
	if($_RQ['storeid']){
		$params['storeid']=intval($_RQ['storeid']);
		$return['params']['storeid']=$_RQ['storeid'];
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.$_RQ['title'].'%';
		$return['params']['title']=$_RQ['title'];
	}
    $orderby='id desc';
	$total='';
	$return['list']=$this->getall('class',$params,array(),'',$orderby);
	foreach($return['list'] as &$item){
		if($item['open_time'] && $item['open_time']<time() && !$item['status']){
			$this->update('class',array('status'=>1),array('id'=>$item['id']));
		}
	}
	$htmls=array(
		'type'=>'list',
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'title','title'=>'售后群名称','type'=>'string'),
			array('name'=>'storeid','width'=>'15','title'=>'所属门店','type'=>'select2','options'=>'stores'),
			array('name'=>'workerid','title'=>'售后主管','type'=>'select2','options'=>'workers'),
			array('name'=>'kechengid','title'=>'绑定使用','type'=>'select2','options'=>'kechengs'),
			array('name'=>'keshi','title'=>'课时','type'=>'string'),
			array('name'=>'xueshengnum','title'=>'用户人数','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio2','options'=>'status'),
			array('name'=>'open_time','title'=>'开班时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'href','title'=>'本班售后','action'=>'/xuesheng.list/fromclass/status=all'),
		)),
		'search'=>array(
			array('type'=>'string','width'=>'15','title'=>'售后群名称','name'=>'title','help'=>''),
			array('name'=>'status','width'=>'15','title'=>'状态','type'=>'radio','options'=>'status'),
			array('name'=>'storeid','width'=>'15','title'=>'所属门店','type'=>'select','options'=>'stores'),
		),
	);
	$return['stores']=$this->getall('store',array('uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
	$return['workers']=$this->getall('worker',array('role'=>11,'storeid'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');	
	$return['kechengs']=$this->getall('kecheng',array('storeid'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');	
	$return['status']=$this->class_status;
	$return['htmls']=$htmls;
	exi($return);
}
?>